package be.fedict.eid.diagnostics.system.windows;

import java.util.List;

import be.fedict.eid.diagnostics.system.ServiceManager;
import be.fedict.eid.diagnostics.system.data.SystemService;
import be.fedict.eid.diagnostics.system.windows.jna.ServiceHandler;

public class WindowsServiceManager implements ServiceManager {

	List<SystemService> services = null;
	
	public List<SystemService> getServices() {
		if (services == null) {
			try {
				services = ServiceHandler.fetchServices();
			} catch (Exception e) {
				return null;
			}
		}
		return services;		
	}
	
	public SystemService getService(String serviceName) {
		List<SystemService> services = getServices();
		for (SystemService systemService : services) {
			if (serviceName.equals(systemService.getServiceName()))
				return systemService;
		}
		return null;
	}

	
}
